<template>
  <div class="messages">
    <Header :isFixed="isFixed"></Header>
    <div class="container" :class="isFixed ? 'mgtop' : ''">
      <div class="row">
        <div class="col-md-2">
          <ListGroup :data="menuData" title="Message category"></ListGroup>
        </div>
        <div class="col-md-10">
          <div class="container_title">
            <TitleControl title="List" desc="Message List" className="slot">
              <div class="title_item">
                <DropDown :data="filterData"></DropDown>
              </div>
            </TitleControl>
          </div>
          <div class="container_list">
            <MessageListControl :data="messageData"></MessageListControl>
          </div>
        </div>
      </div>
      <Pagination :data="messageData"></Pagination>
      <div class="container_aboutme">
        <AboutMeControl></AboutMeControl>
      </div>
    </div>
    <Footer></Footer>
  </div>
</template>

<script>
export default {
  name: "Messages",
  props: {
    isFixed: {
      type: Boolean,
      default() {
        return false;
      },
    },
  },
  data() {
    return {
      menuData: [],
      filterData: [],
      messageData: [],
    };
  },
  created() {
    const token = localStorage.getItem("token");
    this.isLogin = token ? true : false;
    if (!this.isLogin) {
      this.$router.push("/login");
      return;
    }

    let arr = [];
    for (let i = 0; i < 5; i++)
      arr.push({
        name: i,
        path: "/search/:key",
        params: {
          key: i,
        },
      });
    this.menuData = [...arr];

    let filterArr = [];
    for (let i = 0; i < 5; i++)
      filterArr.push({
        name: "Option" + i,
        value: i,
      });
    this.filterData = [...filterArr];

    let messageArr = [];
    for (let i = 0; i < 10; i++)
      messageArr.push({
        id: "123456",
        avater: "https://booking.webestica.com/assets/images/avatar/01.jpg",
        msg: `One morning, when Gregor Samsa woke from troubled dreams, he
                found himself transformed in his bed into a horrible vermin. He
                lay on his armour-like back, and if he lifted his head a little
                he could see his brown belly, slightly domed and divided by
                arches into stiff sections`,
        time: "February 16, 2019",
      });
    this.messageData = [...messageArr];
  },
  components: {
    Header: () =>
      import(
        /* webpackChunkName:'header' */ "@/components/header/components/index.vue"
      ),
    Footer: () =>
      import(
        /* webpackChunkName:'footer' */ "@/components/footer/components/index.vue"
      ),
    ListGroup: () =>
      import(
        /* webpackChunkName:'listGroup' */ "@/components/listGroup/components/index.vue"
      ),
    TitleControl: () =>
      import(
        /* webpackChunkName:'titleControl' */ "@/components/titleControl/components/index.vue"
      ),
    DropDown: () =>
      import(
        /* webpackChunkName:'dropdown' */ "@/components/dropdown/components/index.vue"
      ),
    Pagination: () =>
      import(
        /* webpackChunkName:'pagination' */ "@/components/pagination/components/index.vue"
      ),
    AboutMeControl: () =>
      import(
        /* webpackChunkName:'aboutMeControl' */ "@/components/aboutMeControl/components/index.vue"
      ),
    MessageListControl: () =>
      import(
        /* webpackChunkName:'messageListControl' */ "@/components/messageListControl/components/index.vue"
      ),
  },
};
</script>

<style lang="scss">
.messages {
  .container {
    padding: 0.625rem 0.9375rem;
    &.mgtop {
      margin-top: 3.5rem;
    }
    .es-list-group-title {
      font-size: 0.5rem;
      font-weight: 700;
    }
    .container_title {
    }
    .container_list {
    }
    .container_aboutme {
    }
  }
}
</style>
